<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <script src="js/swiper-4.2.6.min.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" type="text/css" href="css/swiper-4.2.6.min.css"/>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script src="js/public.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/font.js"></script>
    <link rel="stylesheet" href="css/base.css">
    <link rel="stylesheet" href="css/ui.css">
    <link type="text/css" rel="stylesheet" href="css/jedate.css">
    <script type="text/javascript" src="js/jedate.js"></script>
    <title></title>
    <!-- 发票管理 -->
    <style>
        #jedate{
    		top: 0.92rem;
    	}
    </style>
</head>
<body>
<div class="scroll-content2 invoice-admin" style="overflow:auto;background: #f1f1f1;">
    <div class="top-public">
        <span class="public-center">发票管理</span>
        <img src="images/left_icon.png" alt="" class="public-left">
    </div>
    <div class="admBar">
        <div class="barList">
            <span class="listBar order">全部订单</span>
            <ul class="listCon">
                <li class="on" data="1" id="1">全部订单</li>
                <li data="0" id="7">网站开发</li>
                <li data="0" id="8">系统开发</li>
                <li data="0" id="9">代运营服务</li>
            </ul>
        </div>
        <div class="barList">
            <span class="listBar">订单时间</span>
            <input type="text" class="jeinput" id="orderTime" placeholder="YYYY年MM月DD日">
        </div>
    </div>
    <div id="orderList" class="order-list-box">
       <!--<div class="admList">-->
            <!--<img class="check" onclick="check(this)" src="images/icon_choice_normal@2x.png" data="0"/>-->
            <!--<img class="listImg" src="images/photofp1@2x.png"/>-->
            <!--<div class="listContent">-->
                <!--<span class="listName">炭烤薯条等3件商品</span>-->
                <!--<span class="listPrice">￥<i class="peice">3000.00</i></span>-->
                <!--<span class="listTime">2018-09-18 20:30</span>-->
            <!--</div>-->
            <!--<span class="state">已支付</span>-->
        <!--</div>-->
        <!--<div class="admList">-->
            <!--<img class="check" onclick="check(this)" src="images/icon_choice_normal@2x.png" data="0"/>-->
            <!--<img class="listImg" src="images/photofp1@2x.png"/>-->
            <!--<div class="listContent">-->
                <!--<span class="listName">炭烤薯条等3件商品</span>-->
                <!--<span class="listPrice">￥<i class="peice">3000.00</i></span>-->
                <!--<span class="listTime">2018-09-18 20:30</span>-->
            <!--</div>-->
            <!--<span class="state">已支付</span>-->
        <!--</div> -->
        <!--<div class="order-list">-->
            <!--<img class="check" onclick="check(this)" src="images/icon_choice_normal@2x.png" data="0"/>-->
            <!--<div class="list-top">-->
                <!--<span class="name">展示类网站</span>-->
                <!--<span class="state" style="background:#615FD6;">已支付</span>-->
            <!--</div>-->
            <!--<div class="list-center">-->
                <!--<span class="price">￥100000.00</span>-->
                <!--<span class="type">| 续费</span>-->
            <!--</div>-->
            <!--<div class="list-bot">下单时间：<span>2018-09-11 14:54:32</span></div>-->
            <!--&lt;!&ndash;<img src="images/confirm-more.png" alt="" class="more" onclick="more()">&ndash;&gt;-->
        <!--</div>-->
        <div class="order-list">
            <!--<img class="check" onclick="check(this)" src="images/icon_choice_normal@2x.png" data="0"/>-->
            <!--<div class="list-top">-->
                <!--<span class="name">展示类网站2</span>-->
                <!--<span class="state" style="background:#615FD6;">已支付</span>-->
            <!--</div>-->
            <!--<div class="list-center">-->
                <!--<span class="price">￥100000.00</span>-->
                <!--<span class="type">| 续费</span>-->
            <!--</div>-->
            <!--<div class="list-bot">下单时间：<span>2018-09-11 14:54:32</span></div>-->
            <!--<img src="images/confirm-more.png" alt="" class="more" onclick="more()">-->
        </div>
        <!--<div class="order-list">-->
            <!--<img class="check" onclick="check(this)" src="images/icon_choice_normal@2x.png" data="0"/>-->
            <!--<div class="list-top">-->
                <!--<span class="name">展示类网站</span>-->
                <!--<span class="state" style="background:#615FD6;">已支付</span>-->
            <!--</div>-->
            <!--<div class="list-center">-->
                <!--<span class="price">￥100000.00</span>-->
                <!--<span class="type">| 续费</span>-->
            <!--</div>-->
            <!--<div class="list-bot">下单时间：<span>2018-09-11 14:54:32</span></div>-->
            <!--&lt;!&ndash;<img src="images/confirm-more.png" alt="" class="more" onclick="more()">&ndash;&gt;-->
        <!--</div>-->
        <!--<div class="order-list">-->
            <!--<img class="check" onclick="check(this)" src="images/icon_choice_normal@2x.png" data="0"/>-->
            <!--<div class="list-top">-->
                <!--<span class="name">展示类网站</span>-->
                <!--<span class="state" style="background:#615FD6;">已支付</span>-->
            <!--</div>-->
            <!--<div class="list-center">-->
                <!--<span class="price">￥100000.00</span>-->
                <!--<span class="type">| 续费</span>-->
            <!--</div>-->
            <!--<div class="list-bot">下单时间：<span>2018-09-11 14:54:32</span></div>-->
            <!--&lt;!&ndash;<img src="images/confirm-more.png" alt="" class="more" onclick="more()">&ndash;&gt;-->
        <!--</div>-->
    </div>
    <div class="invoNone">
        <img src="images/image_shuju@2x.png"/>
        <span>暂无数据</span>
    </div>
    <div class="admftr">
        <div class="checkAll">
            <img class="qx" src="images/icon_choice_normal@2x.png"/>
            <span>全选</span>
        </div>
        <div class="total">已选择<span class="num">0</span>笔账单</div>
        <div class="prices">
            <div class="priceTop">
                <span class="name">
                    <!--可开票金额-->
                </span>
                <!--<span class="totalAmount">￥<i class="amount">0.00</i></span>-->
            </div>
            <div class="priceBtm">
                <span class="choice">已选金额￥<i class="price">0.00</i></span>
                <span class="owe">欠票金额￥<i class="price">0.00</i></span>
            </div>
        </div>
        <a class="startbtn" href="javascript:;">立即开票</a>
    </div>
	<div class="opacity-gray"></div>
</div>
	<input type="hidden" name="year" id="year" value="" />
	<input type="hidden" name="mouth" id="mouth" value="" />
	<input type="hidden" name="day" id="day" value="" />
</body>
<script>
    $(function(){
        //验证是否登陆
        var user_id = sessionStorage.getItem('userId');
        if (user_id == null) {
            alert('请先登录！');
            window.location.href = 'login.html';
        }
        //清楚发票价格
        sessionStorage.removeItem('invoiceMoney');
        sessionStorage.removeItem('addressType');
        sessionStorage.removeItem('addressId');
        sessionStorage.removeItem('order_id');
        //获取可开发票列表
        getTotal();
    });
    function getTotal() {
        var user_id = sessionStorage.getItem('userId');
        $.ajax({
            url: url() + 'api/Invoice/applyInvoice',    //请求的url地址
            dataType: "JSON",   //返回格式为json
            async: true,//请求是否异步，默认为异步，这也是ajax重要特性
            type: "POST",   //请求方式
            data: {
                user_id:user_id,
            },
            success: function (data) {
                // console.log(data);
                var html1 = '';
                // 请求成功时处理
                if(data.status==1){
                    $.each(data.result, function (i, item) {
                        html1 += '<div class="order-list">';
                        html1 += '<img class="check" onclick="check(this)" data-id="'+ item.order_id +'" src="images/icon_choice_normal@2x.png" data="0"/>';
                        html1 += '<div class="list-top">';
                        html1 += '<span class="name">'+item.goods_name+'</span>';
                        html1 += '<span class="state" style="background:#615FD6;">已支付</span>';
                        html1 += '</div>';
                        html1 += '<div class="list-center">';
                        html1 += '<span>￥<span class="price">'+item.goods_price+'</span></span>';
                        html1 += '<span class="type">| '+item.order_type    +'</span>';
                        html1 += '</div>';
                        html1 += '<div class="list-bot">下单时间：<span>'+item.add_time+'</span></div>';
                        html1 += '</div>';
                    });
                    $('#orderList').html(html1);
                } else {
                    html1 += '<div class="order-list">';
                    html1 += '<div class="list-top">';
                    html1 += '<span class="name">暂无数据</span>';
                    html1 += '</div>';
                    html1 += '</div>';
                    console.log(data.msg);
                    $('#orderList').html(html1);
                }
            }
        });
    }
</script>
<script>
$('.public-left').click(function(){
    // window.history.go(-1);
    window.location.href = 'invoice.html';
});
jeDate("#orderTime",{
    isShow:true,
    theme:{ bgcolor:"#f1f1f1",color:"#000", pnColor:"#9B9B9B"},
    format: "YYYY-MM-DD",
    donefun: function(obj){
        //this    而this指向的都是当前实例
        // console.log(obj.elem);     //得到当前输入框的ID
        // console.log(obj.val);      //得到日期生成的值，如：2017-06-16
        //得到日期时间对象，range为false
        // console.log(obj.date);    //这里是对象
        $('#year').val(obj.date[0]['YYYY']);
        $('#mouth').val(obj.date[0]['MM']);
        $('#day').val(obj.date[0]['DD']);
        obj.date = {YYYY: 2017, MM: 08, DD: 18, hh: 10, mm: 25, ss: 10};

        var new_date = obj.val;
        var user_id = sessionStorage.getItem('userId');
        $.ajax({
            url: url() + 'api/Invoice/applyInvoice',    //请求的url地址
            dataType: "JSON",   //返回格式为json
            async: true,//请求是否异步，默认为异步，这也是ajax重要特性
            type: "POST",   //请求方式
            data: {
                user_id:user_id,
                new_date:new_date,
            },
            success: function (data) {
                console.log(data);
                var html1 = '';
                // 请求成功时处理
                if(data.status==1){
                    $.each(data.result, function (i, item) {
                        html1 += '<div class="order-list">';
                        html1 += '<img class="check" onclick="check(this)" src="images/icon_choice_normal@2x.png" data="0"/>';
                        html1 += '<div class="list-top">';
                        html1 += '<span class="name">'+item.goods_name+'</span>';
                        html1 += '<span class="state" style="background:#615FD6;">已支付</span>';
                        html1 += '</div>';
                        html1 += '<div class="list-center">';
                        html1 += '<span>￥<span class="price">'+item.goods_price+'</span></span>';
                        html1 += '<span class="type">| '+item.order_type+'</span>';
                        html1 += '</div>';
                        html1 += '<div class="list-bot">下单时间：<span>'+item.add_time+'</span></div>';
                        html1 += '</div>';
                    });
                    $('#orderList').html(html1);
                } else {
                    html1 += '<div class="order-list">';
                    html1 += '<div class="list-top">';
                    html1 += '<span class="name">暂无数据</span>';
                    html1 += '</div>';
                    html1 += '</div>';
                    console.log(data.msg);
                    $('#orderList').html(html1);
                }
            }
        });
    }
});

//判断里面有没有数据
var invoList=$('.order-list-box').children().length;
if(invoList<=0){
    $('.order-list-box').hide();
    $('.invoNone').show()
}

//全选
$(".checkAll").click(function(){
       // console.log(this);
    var check=$(this).find('.qx').attr('data');
    if(check==0){
        $(this).find('.qx').attr('src','images/icon_choice_click@2x.png');
        $(this).find('.qx').attr('data',1);
        $('.check').attr('src','images/icon_choice_click@2x.png');
        $('.check').attr('data',1);
        $('.startbtn').addClass('OnBtn');
    }else{
        $(this).find('.qx').attr('src','images/icon_choice_normal@2x.png');
        $(this).find('.qx').attr('data',0);
        $('.check').attr('src','images/icon_choice_normal@2x.png');
        $('.check').attr('data',0);
        $('.startbtn').removeClass('OnBtn');
    }
    allPrice();
    checkNum();
});

//单选
function check(this5){
    var check=$(this5).attr('data');
    if(check==0){
        $(this5).attr('src','images/icon_choice_click@2x.png');
        $(this5).attr('data',1);
        $('.qx').attr('src','images/icon_choice_click@2x.png');
        $('.qx').attr('data',1);
        $('.startbtn').addClass('OnBtn')
    }else{
        $(this5).attr('src','images/icon_choice_normal@2x.png');
        $(this5).attr('data',0);
        $('.qx').attr('src','images/icon_choice_normal@2x.png');
        $('.qx').attr('data',0);
        $('.startbtn').removeClass('OnBtn')
    }
    allPrice();
    checkNum();
}
    //数量
function checkNum(){
    var num=0;
    $(".check").each(function(){
        if($(this).attr("data") == 1){
//              var b=$($(this).parent().find('.count')).html();
            num+=Number(1);
        }
    });
    $(".total .num").html(num);
}
function allPrice(){
    var sum=0;
    $(".check").each(function(){
        if($(this).attr("data") == 1){
            var a=$($(this).parent().find('.price')).html();    //单类商品数量
            sum+=Number(a);
        }
    });
    sessionStorage.setItem('invoiceMoney',sum);
    $(".choice .price").html(sum);
    $("#totalAmount .price").html(sum);
}

//选择订单
var show=false;
$('.listBar').on('click',function(){
    if(show == false){
        $('.listCon').animate({
            height:"2.05rem",
        },200).show();
        $(this).addClass('barOn');
        $('.opacity-gray').animate({
            height:"100%",
        },100).show();
        show = true;
    }else{
        $(this).removeClass('barOn');
        $('.listCon').animate({
            height:"0",
        },200).hide();
        $('.opacity-gray').animate({
            height:"0",
        },100).hide();
        show=false
    }

    //点击遮罩层
    $('.opacity-gray ').on('click',function(){
        $('.order').find('.listBar').removeClass('barOn');
        $('.listCon').animate({
            height:"0",
        },200).hide();
        $('.opacity-gray').animate({
            height:"0",
        },100).hide()
    })
})
$('.listCon li').on('click',function(){
    var index=$(this).html();
    $(this).addClass('on').siblings().removeClass('on');
    $('.order').html(index);
    var category_id = $(this)[0].id;
    var user_id = sessionStorage.getItem('userId');
    $.ajax({
        url: url() + 'api/Invoice/applyInvoice',    //请求的url地址
        dataType: "JSON",   //返回格式为json
        async: true,//请求是否异步，默认为异步，这也是ajax重要特性
        type: "POST",   //请求方式
        data: {
            user_id:user_id,
            category_id:category_id,
        },
        success: function (data) {
            console.log(data);
            var html1 = '';
            // 请求成功时处理
            if(data.status==1){
                $.each(data.result, function (i, item) {
                    html1 += '<div class="order-list">';
                    html1 += '<img class="check" onclick="check(this)" src="images/icon_choice_normal@2x.png" data="0"/>';
                    html1 += '<div class="list-top">';
                    html1 += '<span class="name">'+item.goods_name+'</span>';
                    html1 += '<span class="state" style="background:#615FD6;">已支付</span>';
                    html1 += '</div>';
                    html1 += '<div class="list-center">';
                    html1 += '<span>￥<span class="price">'+item.goods_price+'</span></span>';
                    html1 += '<span class="type">| '+item.order_type    +'</span>';
                    html1 += '</div>';
                    html1 += '<div class="list-bot">下单时间：<span>'+item.add_time+'</span></div>';
                    html1 += '</div>';
                });
                $('#orderList').html(html1);
            } else {
                html1 += '<div class="order-list">';
                html1 += '<div class="list-top">';
                html1 += '<span class="name">暂无数据</span>';
                html1 += '</div>';
                html1 += '</div>';
                console.log(data.msg);
                $('#orderList').html(html1);
            }
        }
    });
})

var arrId = [];
$('.startbtn').click(function(){
    $('.check').each(function(){
        if($(this).attr('data') == 1){
            arrId.push(parseInt($(this).attr('data-id')));
        }
    })
    if(arrId == []){

    }else{
        window.sessionStorage.setItem('order_id',arrId);
        window.location.href = 'invoice_info.html';
    }
})
</script>
</html>






